cmake_minimum_required(VERSION 2.8.4)

SET(PRJ_NAME 				pwshdll)

SET(PRJ_ROOTDIR				${CMAKE_CURRENT_SOURCE_DIR} )
SET(DLL_DIR					"D:/20007387/DLL")

PROJECT(${PRJ_NAME} 		C CXX)
MESSAGE(STATUS "---PowerShell call C-DLL.")
MESSAGE(STATUS "@@@Must add '${DLL_DIR}' to Windows system environment variable 'Path' first.")
MESSAGE(STATUS "@@@CMake cmd -> cmake -G \"MinGW Makefiles\" ..")

INCLUDE_DIRECTORIES( 
	"${PRJ_ROOTDIR}"
)

LINK_DIRECTORIES(
	"${PRJ_ROOTDIR}/build"
)
	
	SET(cflags	-std=gnu99)
	ADD_DEFINITIONS(${cflags})

	ADD_LIBRARY(fx0 SHARED ${PRJ_ROOTDIR}/fx0.c)

add_custom_command(TARGET fx0
			   	   POST_BUILD
	#COMMAND "${CMAKE_COMMAND}" -E remove_directory  "${DLL_DIR}"
	COMMAND "${CMAKE_COMMAND}" -E make_directory 	 "${DLL_DIR}"
	COMMAND "${CMAKE_COMMAND}" -E copy libfx0.dll 	 "${DLL_DIR}"  VERBATIM
	COMMAND "${CMAKE_COMMAND}" -E remove libfx0.dll		VERBATIM  
	COMMAND "${CMAKE_COMMAND}" -E remove libfx0.dll.a   VERBATIM  
)
